package com.ytzl.controller;

import com.ytzl.common.CodeResultEnums;
import com.ytzl.common.R;
import com.ytzl.common.ResponseDataUtils;
import com.ytzl.modul.ItripUserLinkUser;
import com.ytzl.service.ItripUserLinkUserService;
import com.ytzl.vo.ItripAddUserLinkUserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Collection;

@RestController
@RequestMapping("/api/userinfo")
@Slf4j
public class UserInfoController {

    @Resource
    private ItripUserLinkUserService linkUserService;
    //新增常用联系人
    @PostMapping("/adduserlinkuser")
    public R<ItripAddUserLinkUserVO> adduserlinkuser(ItripAddUserLinkUserVO addUserLinkUserVO){
        //添加信息为空
        if (addUserLinkUserVO==null){
            return ResponseDataUtils.buildError(CodeResultEnums.SUBMIT_IS_EMPTY);
        }
        ItripUserLinkUser linkUser=new ItripUserLinkUser();
        linkUser.setLinkidcard(addUserLinkUserVO.getLinkIdCard());
        linkUser.setLinkidcardtype(addUserLinkUserVO.getLinkIdCardType());
        linkUser.setLinkusername(addUserLinkUserVO.getLinkUserName());
        linkUser.setUserid(addUserLinkUserVO.getUserId());
        if (linkUserService.save(linkUser)){
            return ResponseDataUtils.buildSuccess(CodeResultEnums.SUCCESS);
        }
        return ResponseDataUtils.buildError(CodeResultEnums.NEW_LINK_USER_ERROR);
    }

    //删除常用联系人
    @GetMapping("/deluserlinkuser")
    public R deluserlinkuser(Integer[] ids){
        for (Integer item:ids){
            System.out.println("=="+item);
        }
        return null;
    }

    //查询常用联系人
    @PostMapping("/queryuserlinkuser")
    public R queryuserlinkuser(){
        return null;
    }

    //修改常用联系人
    @PostMapping("/modifyuserlinkuser")
    public R modifyuserlinkuser(){
        return null;
    }
}
